package com.mingmen.supplier.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mingmen.supplier.R;
import com.mingmen.supplier.adapter.NoticeAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;


public class NoticeFragment extends Fragment {


    @BindView(R.id.text_yijujue)
    TextView text_yijujue;

    Unbinder unbinder;
    @BindView(R.id.layout_all)
    LinearLayout layout_all;
    @BindView(R.id.text_weichuli)
    TextView text_weichuli;

    int flag = 0;
    @BindView(R.id.recycle_List)
    RecyclerView recycle_List;
    NoticeAdapter noticeAdapter;
    List<String> dataList = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_practive, null);
        unbinder = ButterKnife.bind(this, view);
        recycle_List.setLayoutManager(new LinearLayoutManager(getActivity()));
        noticeAdapter = new NoticeAdapter(getActivity(), dataList);
        recycle_List.setAdapter(noticeAdapter);
        for (int i = 0; i < 10; i++) {
            dataList.add("Item" + i);
        }
        noticeAdapter.setDataList(dataList);
        return view;

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.text_weichuli, R.id.text_yijujue, R.id.layout_all})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.text_weichuli:
                layout_all.setBackground(getActivity().getResources().getDrawable(R.mipmap.weichuolileft));
                text_yijujue.setTextColor(getActivity().getResources().getColor(R.color.normal_bluetextcolor));
                text_weichuli.setTextColor(getActivity().getResources().getColor(R.color.white));
                 flag = 1;
                break;
            case R.id.text_yijujue:
                layout_all.setBackground(getActivity().getResources().getDrawable(R.mipmap.weichuoliright));
                 text_weichuli.setTextColor(getActivity().getResources().getColor(R.color.normal_bluetextcolor));
                text_yijujue.setTextColor(getActivity().getResources().getColor(R.color.white));

                break;
            case R.id.layout_all:
                break;
        }
    }
}
